home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Ken Long / OvalsDoodadd-1.2-c / Think / Ovals.c < prev    next >
Encoding:
Text File  |  1994-12-04  |  19.0 KB  |  640 lines  |  [TEXT/KAHL]

  1. //•-----------------------------------------------------------------------•//
  2. //• Ovals.c                                                                  •//
  3. //• Ploppyright (P) 1993 Kenneth A. Long.  No rights reserved.              •//
  4. //•-----------------------------------------------------------------------•//
  5.  
  6. //•-----------------------------------------------------------------------•//
  7. //• I got the oval thing from an old public domain .c file by Greg Corson •//
  8. //• (which I've included, so you can see all the wrong character case).      •//
  9. //• The .c file was called "Display.c" and was merely a program to open a •//
  10. //• text file and display the contents.  The oval part was kinda cool, so •//
  11. //• put it in here by itself, stripped all the extra trash, added some      •//
  12. //• controls from "EarthPlot 3.0" and modified them for this.  I have      •//
  13. //• learned a few things in making this thing work.  Maybe you can, too.  •//
  14. //•-----------------------------------------------------------------------•//
  15. //• Be sure to try changes, as in the "Ovalize" routine suggestions.      •//
  16. //•-----------------------------------------------------------------------•//
  17.  
  18. //•-----------------------------------------------------------------------•//
  19. //• -------------------------------ENJOY!-------------------------------- •//
  20. //•-----------------------------------------------------------------------•//
  21.  
  22. #include <controls.h>    //• I called these so I could access them with
  23. #include <quickdraw.h>  //• CMaster, without a big SFGetFile path search.
  24. #include <windows.h>    //• They were "called" in the original, too.
  25. #include <menus.h>
  26. #include <events.h>
  27. #include <packages.h>    //• This is the only one not in MacHeaders.
  28. #include <fonts.h>
  29.  
  30. #include "OvalGlobals.h"//• Raiders of the Lost EarthPlot Source.
  31.  
  32. enum {
  33.     appleID = 1, 
  34.     fileID,             //• Must be "2" huh?
  35.     editID              //• Must be "3" (duh).
  36. };
  37.     
  38. #define    ours(w) ((theWindow != NULL) && (w == theWindow))    //• From MiniEdit.
  39.  
  40. MenuHandle        appleMenu, fileMenu, editMenu;
  41.  
  42. Rect            dragRect, ovalRect, totalBarRect, vOffBarRect, 
  43.                 hOffBarRect, controlsRect;
  44.                 
  45. Boolean            doneFlag, temp, Resized;
  46. EventRecord      myEvent;
  47. short            code, refNum;
  48. WindowRecord     wRecord;
  49. WindowPtr        theWindow, whichWindow;
  50. GrafPtr            tempPort;
  51. short            theMenu, theItem,
  52.                 fileOpen, width, fd1,
  53.                 numH_Ovals, numV_Ovals, hOffset, vOffset,
  54.                 j, i;
  55.  
  56. long            count;
  57. char            tempBuf[32];
  58. Rect            windowBounds = { 0, 0, 384, 512 };    //• Our window size.
  59. Point            thePoint;
  60.  
  61. //•-----------------------------------------------------------------------•//
  62.  
  63. //•-----------------------------------------------------------------------•//
  64. //• HandleMenu (theMenu, theItem)---this subroutine processes commands      •//
  65. //• from the menu bar.                                                      •//
  66. //• theMenu is the menu ID, theItem is the item number in the menu          •//
  67. //•-----------------------------------------------------------------------•//
  68.  
  69.  
  70. DoSplash ()
  71. {
  72.     long ticks;
  73.     
  74.     DrawThemStrangs ();        //• The window is already up, so we draw in it.
  75.     Delay (240L, &ticks);    //• 60 ticks per second = 4 seconds of fame.
  76.     EraseRect (&ovalRect);    //• Dump it and move on.
  77.     AddControls ();            //• We didn't want them spoiling our bragging.
  78.     DrawControlLabels ();    //• Send the names to Chicago!
  79.     
  80. }
  81.  
  82. //•-----------------------------------------------------------------------•//
  83.  
  84. HandleMenu (theMenu, theItem)
  85. short theMenu, theItem;
  86. {
  87.     char name [256];
  88.     
  89.     switch (theMenu)
  90.     {
  91.         case appleID:                //• Mouse down in apple menu.
  92.             if (theItem == 1)        //• The "About" item.
  93.             {
  94.                 DrawThemStrangs ();
  95.             }
  96.             else
  97.                 {
  98.                     GetItem (appleMenu, theItem, name);
  99.                     refNum = OpenDeskAcc (name);
  100.                     SetPort (theWindow);
  101.             }
  102.         break;
  103.         case fileID:    //• Mouse down in file menu.
  104.             switch (theItem)
  105.             {
  106.                 case 1:        //• Open file?  For what? We're not using it.
  107.                 case 2:        //• Close file. For what? We're not using it.
  108.                 break;
  109.             
  110.                 case 3:        //• Quit.
  111.                     doneFlag = true;    //• Yep!  When we quit, we're done.
  112.                 break;
  113.             }
  114.         break;
  115.             
  116.         case editID:                    //• Process system edit events.
  117.             SystemEdit (theItem-1);        
  118.         break;
  119.     }
  120.     HiliteMenu (0);
  121. }
  122. //•-----------------------------------------------------------------------•//
  123. //• SetUpMenus ()    "Hot wires" them in, rather that a resource used.
  124. //• This subroutine sets up menu bar and reads in desk accessory menu
  125. //•-----------------------------------------------------------------------•//
  126.  
  127. SetUpMenus ()
  128. {
  129.     InsertMenu (appleMenu = NewMenu (appleID, "\p\024"), 0);
  130.     InsertMenu (fileMenu = NewMenu (fileID, "\pFile"), 0);
  131.     InsertMenu (editMenu = NewMenu (editID, "\pEdit"), 0);
  132.     DrawMenuBar ();
  133.     AppendMenu (appleMenu, "\pAbout Oval Doodadd…");
  134.     AddResMenu (appleMenu, 'DRVR');
  135.     AppendMenu (fileMenu, "\pWhy?;What?;Quit/Q");
  136.     AppendMenu (editMenu, "\pUndo/Z; (-;Cut/X;Copy/C;Paste/V;Clear");
  137. }
  138.  
  139. //•-----------------------------------------------------------------------•//
  140.  
  141. ControlsDataUpdate ()
  142. {
  143.     char s [64];
  144.  
  145.     MoveTo (72, 350);                                //• 72 over, 350 down.
  146.     
  147.     //• Change the value stored in a short (integer) to a string.
  148.     //• That is, turn the value into a "picture" of the value.
  149.     //• And get that value from whatever the control is set at.
  150.     NumToString (GetCtlValue (hOvalTotalBar), s);
  151.     
  152.     //• Make sure there is nothing in the place we'll draw the value picture.
  153.     EraseRect (&H_OvalTotalDataRect);
  154.     
  155.     //• Draw a "picture" of the value gotten from the control.
  156.     DrawString (s);
  157.  
  158.     //• Do it all agoin someplace else.
  159.     MoveTo (182, 350);
  160.     NumToString (GetCtlValue (vOvalTotalBar), s);
  161.     EraseRect (&V_OvalTotalDataRect);
  162.     DrawString (s);
  163.     
  164.     MoveTo (292, 350);
  165.     NumToString (GetCtlValue (verticalBar), s);
  166.     EraseRect (&verticalDataRect);
  167.     DrawString (s);
  168.     
  169.     MoveTo (412, 350);
  170.     NumToString (GetCtlValue (horizontalBar), s);
  171.     EraseRect (&horizontalDataRect);
  172.     DrawString (s);
  173. }
  174.  
  175. //•-----------------------------------------------------------------------•//
  176.  
  177. InitRectangles ()
  178. {
  179.     SetRect (&ovalRect, 6, 25, 507, 320);    //• Shortened for control space.
  180.     
  181.     SetRect (&controlsRect, 0, 320, 512, 384);    //• Just for a separate
  182.                                                 //• area for the controls.
  183.                                                 //• Not really needed/used.
  184.  
  185.     SetRect (&buttonRect,      440, 354, 500, 374);    //• Our Draw Button.
  186.  
  187.     SetRect (&H_OvalTotalBarRect,      10, 358, 100, 374);    //• Scroll Bars.
  188.     SetRect (&V_OvalTotalBarRect,     110, 358, 210, 374);
  189.     SetRect (&verticalBarRect,         220, 358, 320, 374);
  190.     SetRect (&horizontalBarRect,     330, 358, 430, 374);
  191.  
  192.  
  193.     SetRect (&H_OvalTotalDataRect,      72, 330, 102, 350);    //• For data.
  194.     SetRect (&V_OvalTotalDataRect,     182, 330, 212, 350);    //• Or "labels."
  195.     SetRect (&verticalDataRect,     292, 330, 322, 350);
  196.     SetRect (&horizontalDataRect,     412, 330, 432, 350);
  197. }
  198.  
  199. //•-----------------------------------------------------------------------•//
  200.  
  201. DrawControlLabels ()
  202. {
  203.     GrafPtr    thePort;
  204.     GetPort (&thePort);
  205.  
  206.     DrawControls (thePort);            //• Freshen up the controls, whether
  207.                                     //• neede or not.
  208.     TextFont (0);                    //• Make sure we're in Chicago.
  209.     MoveTo (10, 350);                //• Go here.
  210.     DrawString ("\pH # Ovals:");    //• Draw this profound statement.
  211.     MoveTo (110, 350);                //• Move.
  212.     DrawString ("\pV # Ovals:");    //• Do.
  213.     MoveTo (220, 350);                //• Etcetera.
  214.     DrawString ("\pV Offset:");
  215.     MoveTo (330, 350);
  216.     DrawString ("\pH Offset:");
  217.     
  218.     ControlsDataUpdate ();            //• Make the output track, in case it
  219. }                                    //• was messed up.
  220.  
  221. //•-----------------------------------------------------------------------•//
  222.  
  223. Track (ControlHandle theControl, short partCode)
  224. {
  225.  
  226.     short        i, step;
  227.     long    wait;
  228.     long    waited;
  229.     char    s [128];
  230.  
  231.     wait = 5; //• ticks.
  232.  
  233.     if (partCode == 0)                 //• If we ain't clickin' then don't
  234.         return;                        //• hang around here!
  235.     
  236.     switch (partCode)                 //• If we be clickin' then get to
  237.     {                                //• switchin'!
  238.         case inUpButton:
  239.             step = -1;                //• Pick it down by 1.
  240.         break;
  241.         
  242.         case inDownButton:
  243.             step = 1;                //• Bump it up 1.
  244.         break;
  245.         
  246.         case inPageUp:
  247.             step = -10;                //• Subtracts 10 increments.
  248.         break;
  249.         
  250.         case inPageDown:
  251.             step = 10;                //• Adds up 10 increments.
  252.         break;
  253.     
  254.         case inButton:
  255.             EraseRect (&ovalRect);    //• In case you hit the button, it draws.
  256.             Ovalize ();                //• That's handy!
  257.         break;
  258.     }
  259.     //• Whichever one of the cases switched to, make it so, Number One, ...
  260.     i = GetCtlValue (theControl) + step;    //• by assigning the value of
  261.                                             //• the control's setting to "i"
  262.                                             //• AND the "step" amount +/-.
  263.     //• Handle the individual controls.
  264.     if (*theControl == *hOvalTotalBar)
  265.     {
  266.         if (i > 148)         //• Whatever "i" is, it's 0 to 148.
  267.             i = 148;
  268.         if (i < 0) 
  269.             i = 0;
  270.  
  271.         SetCtlValue (theControl, i);    //• Set that control to what it IS.
  272.  
  273.         //• Wibe off the drawing surface.
  274.         EraseRect (&H_OvalTotalDataRect);
  275.         
  276.         MoveTo (72, 350);                //• Go here.
  277.         
  278.         //• Same as before.
  279.         NumToString (GetCtlValue (hOvalTotalBar), s);
  280.         DrawString (s);
  281.         Delay (wait, &waited);
  282.     }
  283.     //• And so on..................................!
  284.     if (*theControl == *vOvalTotalBar) 
  285.     {
  286.         if (i > 251) 
  287.             i = 251;
  288.         if (i <  0) 
  289.             i = 0;
  290.  
  291.         SetCtlValue (theControl, i);
  292.  
  293.         EraseRect (&V_OvalTotalDataRect);
  294.         MoveTo (182, 350);
  295.         NumToString (GetCtlValue (vOvalTotalBar), s);
  296.         DrawString (s);
  297.         Delay (wait, &waited);
  298.     }
  299.  
  300.     if (*theControl == *verticalBar) 
  301.     {
  302.         if (i > 50) 
  303.             i = 50;
  304.         if (i <  0) 
  305.             i = 0;
  306.  
  307.         SetCtlValue (theControl, i);
  308.  
  309.         EraseRect (&verticalDataRect);
  310.         MoveTo (292, 350);
  311.         NumToString (GetCtlValue (verticalBar), s);
  312.         DrawString (s);
  313.         Delay (wait, &waited);
  314.     }
  315.     
  316.     if (*theControl == *horizontalBar) 
  317.     {
  318.         if (i > 49)     //• If the counter's more than 49,
  319.             i = 49;        //• then the count is 49.
  320.         if (i <  0)     //• Same for less than 49.
  321.             i = 0;        //• But the it's zero.
  322.  
  323.         SetCtlValue (theControl, i);
  324.  
  325.         EraseRect (&horizontalDataRect);
  326.         MoveTo (412, 350);
  327.         NumToString (GetCtlValue (horizontalBar), s);
  328.         DrawString (s);
  329.         Delay (wait, &waited);
  330.     }
  331.     
  332.     if (*theControl == goButton)        //• If we click in the "Draw"
  333.     {                                    //• button, we DRAW!!!!!!!!
  334.         EraseRect (&ovalRect);            //• (duh)
  335.         Ovalize ();
  336.     }
  337. }
  338.  
  339. //•-----------------------------------------------------------------------•//
  340. //• It's the content of the controls we're interested in.                  •//
  341. //•-----------------------------------------------------------------------•//
  342.  
  343. DoContent(WindowPtr theWindow, EventRecord *theEvent)
  344. {    
  345.     ControlHandle    theControl;
  346.     short                partCode;
  347.     char            s [100];
  348.     WindowPtr myWindow;
  349.  
  350.     partCode = FindControl (theEvent->where, theWindow, &theControl);
  351.  
  352.     if (partCode) 
  353.     {
  354.         switch (partCode) 
  355.         {        
  356.             case inUpButton:
  357.             case inDownButton:
  358.             case inPageUp:
  359.             case inPageDown:
  360.                 partCode = TrackControl (theControl, theEvent->where, 0L);
  361.                 Track (theControl, partCode);
  362.                 ControlsDataUpdate ();
  363.             break;
  364.             
  365.             case inThumb:
  366.                 partCode = TrackControl (theControl, theEvent->where, 0L);
  367.                 ControlsDataUpdate ();
  368.             break;
  369.             
  370.             case inButton:        //• Not this again!
  371.                 partCode = TrackControl (theControl, theEvent->where, 0L);
  372.                 EraseRect (&ovalRect);
  373.                 Ovalize ();
  374.             break;
  375.         }
  376.     }
  377. }
  378.  
  379. //•-----------------------------------------------------------------------•//
  380.  
  381. Ovalize ()            //• Get yer MoJo workin'!
  382. {
  383.     Rect tempRect;
  384.  
  385.     SetPort (theWindow);
  386.     HiliteWindow (theWindow, false);
  387.     
  388.         //• The # of ovals is the same as the control value the user set.
  389.         numH_Ovals = GetCtlValue (hOvalTotalBar);    //• "=" means "is".
  390.         numV_Ovals = GetCtlValue (vOvalTotalBar);    
  391.         
  392.         //• The oval offset is the same as the control value the user set.
  393.         vOffset    = GetCtlValue (verticalBar);
  394.         hOffset    = GetCtlValue (horizontalBar);
  395.     
  396.         BlockMove (&ovalRect, &tempRect, (long)sizeof ovalRect);
  397.         for (j = 0; j < numV_Ovals; j++)    //• Change horizontal ovals here.
  398.         {
  399.             FrameOval (&tempRect);        //• Comment this line out and then
  400. //•         FrameRect (&tempRect);        //• uncomment this line for square.
  401.             InsetRect (&tempRect, vOffset, 0);
  402.         }
  403.         BlockMove (&ovalRect, &tempRect, (long)sizeof ovalRect);
  404.         for (j = 0; j < numH_Ovals; j++)
  405.         {
  406.             FrameOval (&tempRect);        //• Comment this line out and then
  407. //•         FrameRect (&tempRect);        //• uncomment this line for square.
  408.             InsetRect (&tempRect, 0, hOffset);
  409.         }
  410. }
  411.  
  412. //•-----------------------------------------------------------------------•//
  413.  
  414. DoInitManagers ()                    //• Hire these guys to manage stuff.
  415. {    
  416.     InitGraf (&thePort);
  417.     InitFonts ();
  418.     FlushEvents (everyEvent, 0);
  419.     InitWindows ();
  420.     InitMenus ();
  421.     TEInit ();
  422.     InitDialogs (0L);
  423.     InitCursor ();
  424. }
  425.  
  426. //•-----------------------------------------------------------------------•//
  427. //• The window is hot-wired in, too.  Why mess with a resource for this 
  428. //• little thing?
  429. //•-----------------------------------------------------------------------•//
  430.  
  431. SetUpWindow ()
  432. {
  433.     //• Setup the drag Rectangle so part of the window will always be visible.
  434.     dragRect = screenBits.bounds;
  435.     
  436.     //• Create the window and set the current port to the window port.
  437.     theWindow = NewWindow (&wRecord, &windowBounds, "\p", true, 2, 
  438.              (WindowPtr)-1L, false, 0L);
  439.     SetPort (theWindow);
  440.     
  441.     //• get the Rectangle for the current window and put it in ovalRect.
  442.     BlockMove (&thePort->portRect, &ovalRect, (long) sizeof ovalRect);
  443.     width = ovalRect.right  - ovalRect.left;
  444.         
  445.     InitRectangles ();        //• Now that we have a window, put things in it.
  446.  
  447. }
  448. //•-----------------------------------------------------------------------•//
  449.  
  450. AddControls ()
  451. {
  452.     //• A new button.
  453.     goButton    = NewControl (theWindow, &buttonRect, 
  454.                                 "\pDraw", true,  0L, 0L, 0L, 0, 0L);    
  455.     
  456.     //• And 4 new scroll bars.
  457.     hOvalTotalBar    = NewControl (theWindow, &H_OvalTotalBarRect, 
  458.                                         "", true,  1, 1, 148, 16, 0L);
  459.                                             
  460.     horizontalBar    = NewControl (theWindow, &horizontalBarRect,  
  461.                                         "", true,  1, 1, 49, 16, 0L);    
  462.  
  463.     vOvalTotalBar    = NewControl (theWindow, &V_OvalTotalBarRect, 
  464.                                         "", true,  1, 1, 251, 16, 0L);
  465.                                             
  466.     verticalBar        = NewControl (theWindow, &verticalBarRect,      
  467.                                         "", true,  1, 1, 50, 16, 0L);    
  468. }
  469.  
  470. //•-----------------------------------------------------------------------•//
  471. //• Centers the strings in the window.                                      •//
  472. //•-----------------------------------------------------------------------•//
  473.  
  474. Center (char *str)
  475. {
  476.     //• Move what?  The pen to draw with.  Notice we don't use a pencil?
  477.     //• "right" and "left" and "width" imply horizontal.
  478.     //• Width is assigned "ovalRect.right" (507) minus "ovalRect.left" (6).
  479.     //• That makes "width" 501.
  480.     //• 501 minus the width of "str" leaves us with an amount.
  481.     //• Then the "0" means we are at the top - or vertical 0.
  482.     //• So we are at the top and 501 minus the StringWidth, divided by 2
  483.     //• from the left.  If the StringWidth is 101, we're at 200.  Dig?
  484.     Move (((width - StringWidth (str)) / 2), 0);
  485.     
  486.     DrawString (str);            //• We draw the string there.
  487.     
  488.     //• Am I supposed to explain this one, too?
  489.     Move (-(theWindow->pnLoc.h), (theWindow->txSize) + 2);
  490. }
  491.  
  492. //•-----------------------------------------------------------------------•//
  493.  
  494. DrawThemStrangs ()
  495. {
  496.     EraseRect (&ovalRect);
  497.     TextFont (courier);        //• Could use a procID number for the font.
  498.     TextFace (outline);        //• Without this fragment, it would be plain.
  499.     TextSize (24);            //• Big ol' typewriter font!
  500.     MoveTo (ovalRect.left, ovalRect.top + 20);    //• Start at down 20.
  501.     Center ("\pOval Drawing Doodadd");    //• Did I spell "doodadd right?
  502.                                         //• Always take a "\p" first!
  503.     Move (0, -10);
  504.     TextFont (monaco);
  505.     TextSize (9);
  506.     TextFace (bold);
  507.     Center ("\pPublic Domain (P) 1993 by Kenneth A. Long");
  508.     
  509.     Move (0, 10);
  510.     TextFont (courier);    
  511.     TextFace (outline);    
  512.     TextSize (14);                    //• 5 points bigger in size.
  513.     Center ("\pitty bitty bytes™");
  514.     
  515.     TextFont (monaco);                //• Change of font duly noted.
  516.     TextFace (bold);                //• The "brazen" style!
  517.     TextSize (9);                    //• The incredible shrinking font.
  518.     Center ("\pkenlong@netcom.com");    //• I know this guy!
  519.     
  520.     TextFace (0);        //• Zero = systemFont = Chicago (on my LC).
  521.     Move (0, 20);        //• Drop that pen down 20 points.
  522.     
  523.     Center ("\pGleaned from a file display program from 1985 by Greg Corson.");
  524.     Center ("\pYou should NOT try sell this for profit.  Nobody would buy it.");
  525.  
  526.     TextFont (courier);        //• Font stays the same until you say different.
  527.     TextSize (10);            //• Courier looks bad in 9.
  528.     Move (0, 10);            //• Drop down 10 points.
  529.     Center ("\p\"I Think, therefore I 'C'.\"  Ain't Think C™ v.5.0.4 great!");
  530.  
  531.     Move (0, 10);            //• Drop down 10 points.
  532.     TextFont (monaco);        //• Back to Monaco (stay out of the casinos!).
  533.     TextSize (9);            //• Shrink back to 9 for this font.
  534.     Center ("\pThis program was made to help beginning programmers learn things.");
  535.     Center ("\pFeel free to give this program away to all your friends.");
  536.     Center ("\pPost it on your local board and otherwise distribute it freely");
  537.     Center ("\pThe oval drawing was the least common program feature of Greg's hack.");
  538.  
  539.     Move (0, 20);            //• Drop the pen down 20 for some "gapposis."
  540.     Center ("\pDraws various texts, centered horizontally in a window.");
  541.     Center ("\pDraws concentric ovals incrementing and decrementing in H and V.");
  542.     Center ("\pTeaches about for loops, controls, drawing two things in one window, ");
  543.     Center ("\pone type of \"splash\" screen, putting quotes in coded-in text, and more.");
  544.  
  545.     TextFont (systemFont);        //• Put it back like we found it.
  546.     TextSize (12);                //• Size reverts, too.
  547.     //• Note:  Not putting this font back changed my System parameter font!
  548. }
  549.  
  550. //•-----------------------------------------------------------------------•//
  551.  
  552. MainLoop ()
  553. {
  554.     EventRecord *theEvent;
  555.     
  556.     doneFlag = false;
  557.  
  558.     do 
  559.     {
  560.     SystemTask ();
  561.     temp = GetNextEvent (everyEvent, &myEvent);
  562.     switch (myEvent.what)
  563.     {
  564.         case mouseDown:  //• mouse down, call findwindow to figure out where.
  565.             code = FindWindow (myEvent.where, &whichWindow);
  566.             switch (code)
  567.             {
  568.                 case inMenuBar:    //• in menu bar, execute the menu command. 
  569.                     HandleMenu (MenuSelect (myEvent.where));
  570.                 break;
  571.         
  572.                 case inSysWindow:    //• in desk accessory, call desk manager.
  573.                     SystemClick (&myEvent, whichWindow); 
  574.                 break;
  575.             
  576.                 case inDrag:    //• in drag, call dragWindow to move it.
  577.                     DragWindow (whichWindow, myEvent.where, &dragRect);
  578.                 break;
  579.                 
  580.                 case inContent:    //• in content area, make application window the frontmost.
  581.                     if (whichWindow != FrontWindow ())
  582.                         SelectWindow (whichWindow);
  583.                 else 
  584.                     if (ours (whichWindow))
  585.                         DoContent(whichWindow, &myEvent);
  586.                 break;
  587.             }
  588.         break;
  589.         
  590.         case keyDown:    //• If keydown event, check for menu command key.
  591.             if (myEvent.modifiers & cmdKey)
  592.                 HandleMenu (MenuKey ((char) (myEvent.message & 0377)));
  593.         break;
  594.         
  595.         case autoKey:
  596.         break;
  597.         
  598.         case activateEvt:    //• Application window becomming active, do nothing.
  599.             if ((myEvent.modifiers & 1)&& (((WindowPtr)myEvent.message) == theWindow))
  600.             {
  601.                 DisableItem (editMenu, 0);
  602.                 EnableItem (fileMenu, 0);
  603.                 DrawMenuBar ();
  604.             }
  605.             else
  606.                 {
  607.                     EnableItem (editMenu, 0);
  608.                     DisableItem (fileMenu, 0);
  609.                     DrawMenuBar ();
  610.             }
  611.         break;
  612.         
  613.         case updateEvt:    //• Update event, update the window frame.
  614.             if (((WindowPtr)myEvent.message) == theWindow)
  615.             {
  616.                 BeginUpdate (theWindow);
  617.                 DoContent (whichWindow, &myEvent);
  618.                 ControlsDataUpdate ();
  619.                 EndUpdate (theWindow);
  620.             }
  621.         break;
  622.         }
  623.     } while (doneFlag == 0);
  624. }
  625.  
  626. //•-----------------------------------------------------------------------•//
  627.  
  628. main ()
  629. {
  630.     DoInitManagers ();    //• Hire the managers for our job, here.
  631.  
  632.     SetUpMenus ();        //• Without steak and eggs.
  633.     
  634.     SetUpWindow ();        //• So we have a place to do our thing.
  635.     
  636.     DoSplash ();        //• Brag for 4 seconds.
  637.     
  638.     MainLoop ();        //• Here we go loop-de-loop!
  639. }
  640.